package com.hbnu.system.controller;



import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.AchievementAuthor;
import com.hbnu.system.service.AchievementAuthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (AchievementAuthor)表控制层
 *
 * @author makejava
 * @since 2025-07-22 19:14:14
 */
@RestController
@RequestMapping("/achievementAuthor")
@Api(tags = "咨询报告的作者管理")
public class AchievementAuthorController {
    @Autowired
    private AchievementAuthorService iAchievementAuthorService;
    @ApiOperation("新增科研成果作者")
    @PostMapping("/addauthor")
    public Rest<String> addAuthor(@RequestBody AchievementAuthor achievementAuthor){
        boolean ba = iAchievementAuthorService.addAchievementAuthor(achievementAuthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除作者信息")
    @GetMapping ("/deleteauthor")
    public Rest<String> delete(String id){
        boolean ba1 = iAchievementAuthorService.deleteAchievementAuthor(id);
        return ba1?Rest.success():Rest.failed();
    }
    @ApiOperation("修改作者信息")
    @PostMapping("/updateauthor")
    public Rest<String> updateAuthor(@RequestBody AchievementAuthor achievementAuthor){
        boolean ba2=iAchievementAuthorService.updateAchievementAuthor(achievementAuthor);
        return ba2?Rest.success():Rest.failed();
    }
    @ApiOperation("搜索作者信息")
    @GetMapping("/selectauthor")
    public Rest<List<AchievementAuthor>> selectAuthor(String id){
        List<AchievementAuthor> pa=iAchievementAuthorService.listAuthor(id);
        return Rest.success(pa,pa.size());
    }
}

